﻿Imports DTO
Public Class MonAn_DAL
    Dim connect As Connection
    Dim stringCommand As String
    Dim monAn As MonAn
    Dim ds_MonAn As List(Of MonAn)

    Public Function LoadData() As List(Of MonAn)
        connect = New Connection()
        stringCommand = "Select * From MonAn"
        ds_MonAn = New List(Of MonAn)
        Dim dt As New DataTable()
        dt = connect.LoadData(stringCommand)
        For i As Integer = 0 To dt.Rows.Count - 1
            Dim id As Integer = dt.Rows(i)(0)
            Dim tenMonAn As String = dt.Rows(i)(1).ToString()
            Dim gia As Double = dt.Rows(i)(2)
            monAn = New MonAn(id, tenMonAn, gia)
            ds_MonAn.Add(monAn)
        Next
        Return ds_MonAn
    End Function

    Public Function Insert(ByVal monAn As MonAn)
        connect = New Connection()
        stringCommand = "Insert MonAn(ID,TenMonAn,Gia) Values('" & monAn.ID & "','" & monAn.Tên_Món_Ăn & "','" & monAn.Giá & ")"
        Return connect.ExecuteData(stringCommand)
    End Function
End Class
